<template>
	<view class="p02 info">
		<!-- 余额订单详情 start -->
		<block v-if="type==='balance'">
				<view class="c9 t-c c6">{{info.item == 1?'收入':'支出'}}（元）</view>
				<view class="f60 t-c wei">{{info.money}}</view>
				<view class="f-x-bt mt50 f24">
					<view class="c9">时间</view>
					<view class="">{{info.createdAt}}</view>
				</view>
				<view class="f-x-bt mt10 f24">
					<view class="c9">订单号</view>
					<view class="">{{info.outTradeNo}}</view>
				</view>
				<view class="f-x-bt mt10 f24">
					<view class="c9">订单类型</view>
					<view class="">{{info.note}}</view>
				</view>
				<view class="f-x-bt mt10 f24">
					<view class="c9">账户余额</view>
					<view class="">{{info.currentMoney}}</view>
				</view>
		</block>
		<!-- 余额订单详情 end -->
		<!-- 订单查询详情 start -->
		<block v-else-if="type==='orderQuery'">
			<view class="c9 t-c c6">预计收入（元）</view>
			<view class="f60 t-c wei">{{info.storeActualMoney}}</view>
			<view class="f-x-bt mt10 f24">
				<view class="c9">支付方式</view>
				<view class="">{{info.payModeName}}</view>
			</view>
			<view class="f-x-bt mt50 f24">
				<view class="c9">时间</view>
				<view class="">{{info.createdAt}}</view>
			</view>
			<view class="f-x-bt mt10 f24">
				<view class="c9">订单号</view>
				<view class="">{{info.outTradeNo}}</view>
			</view>
			<view class="f-x-bt mt10 f24">
				<view class="c9">订单类型</view>
				<view class="">{{info.originName}}</view>
			</view>
			<view class="f-x-bt mt10 f24">
				<view class="c9">订单状态</view>
				<view :style="{color:info.state ==1?'#67c23a':'#409eff'}">{{info.stateNote}}</view>
			</view>
			<view class="f-x-bt mt10 f24">
				<view class="c9">实付</view>
				<view class="">{{info.money}}</view>
			</view>
			<view class="f-x-bt mt10 f24">
				<view class="c9">服务费</view>
				<view class="">{{info.serviceMoney}}</view>
			</view>
			<view class="f-x-bt mt10 f24">
				<view class="c9">配送费</view>
				<view class="">{{info.deliveryMoney}}</view>
			</view>
			<view class="f-x-bt mt10 f24">
				<view class="c9">预计收入</view>
				<view class="">{{info.storeActualMoney}}</view>
			</view>
		</block>
		<!-- 订单查询详情 end -->
		<!-- 对账详情 start -->
		<block v-else-if="type==='billDetail'">
			<view class="c9 t-c c6">预计收入（元）</view>
			<view class="f60 t-c wei" style="color: #67c23a;">+{{info.storeActualMoney}}</view>
			<view class="bt-fa wei f36 p20 mt50">商品详情</view>
			<view class="f-x-bt c9" v-for="item in info.goodsArr" :key="item.id">
				<view class="f-y-bt">
					<text class="f30">{{item.name}}</text>
					<text class="f28 ml10">{{item.data}}</text>
				</view>
				<view>x{{item.num}}</view>
				<view>{{item.money}}</view>
			</view>
			<view class="bt-fa wei f36 p20 mt50">订单信息</view>
			<view class="f-x-bt  mt10 f28">
				<view class="c9">订单类型</view>
				<view class="">{{info.originName}}</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">下单渠道</view>
				<view class="">{{info.platformName}}</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">用户信息</view>
				<view class="" v-if="info.userName">{{info.userName}}（UID:{{info.userId}}）</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">下单时间</view>
				<view class="">{{info.createdAt}}</view>
			</view>
			<view v-if="info.takeNo" class="f-x-bt mt10 f28">
				<view class="c9">订单序号</view>
				<view class="">{{info.takeNo}}</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">订单编号</view>
				<view class="">{{info.outTradeNo}}</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">实付金额</view>
				<view class="">￥{{info.money}}</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">付款方式</view>
				<view class="">{{info.payModeName}}</view>
			</view>
			<!-- 其他订单||当面付 -->
			<block v-if="query.type == 2 || query.type == 5">
				<view class="f-x-bt mt10 f28">
					<view class="c9">订单状态</view>
					<view class="">已完成</view>
				</view>
			</block>
			<!-- 外卖订单 -->
			<block v-else-if="query.type == 1">
				<view class="f-x-bt mt10 f28">
					<view class="c9">订单状态</view>
					<view v-if="info.state==5 || info.state==6">已完成</view>
					<view v-else-if="info.state==2 || info.state==3 || info.state==4"  class="">待完成</view>
					<view v-else-if="info.state==9" class="">退款待处理</view>
					<view v-else-if="info.state==8 || info.state==10" class="">已退款</view>
				</view>
			</block>
			<!-- 堂食 -->
			<block v-else-if="query.type == 4">
				<view class="f-x-bt mt10 f28">
					<view class="c9">订单状态</view>
					<view v-if="info.state==3 && ( info.eatType ==1 || info.eatType ==2)">已完成</view>
					<view v-else-if="info.state==2 && ( info.eatType ==1 || info.eatType ==2)"  class="">就餐中</view>
				</view>
			</block>
			<!-- 快餐 -->
			<block v-else-if="query.type == 3">
				<view class="f-x-bt mt10 f28">
					<view class="c9">订单状态</view>
					<view v-if="info.state==2">待接单</view>
					<view v-else-if="info.state==3"  class="">制作中</view>
					<view v-else-if="info.state==4"  class="">已完成</view>
					<view v-else-if="info.state==5"  class="">已取消</view>
					<view v-else-if="info.state==6"  class="">申请退款</view>
					<view v-else-if="info.state==7 && info.refundType==1"  class="">用户申请退款通过</view>
					<view v-else-if="info.state==7 && info.refundType==2"  class="">商家退款</view>
					<view v-else-if="info.state==8"  class="">拒绝退款</view>
					<view v-else-if="info.state==9"  class="">商户拒单并退款</view>
				</view>
			</block>
			<view class="f-x-bt mt10 f28">
				<view class="c9">下单人信息</view>
				<view class="" v-if="info.receivedName">{{info.receivedName}}({{info.receivedTel}})</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9" style="width: 200rpx;">配送地址</view>
				<view class="">{{info.receivedAddress}}</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">备注</view>
				<view class="">{{info.userNote || '无'}}</view>
			</view>
			<block v-if="query.type != 3 && query.type != 4 && query.type != 5">
				<view class="bt-fa wei f36 p20 mt50">配送信息</view>
				<view class="f-x-bt  mt10 f28">
					<view class="c9">配送方式</view>
					<view v-if="info.deliveryMode == 1" class="">商户配送</view>
					<view v-if="info.deliveryMode == 2" class="">达达配送</view>
					<view v-if="info.deliveryMode == 3" class="">点我达配送</view>
					<view v-if="info.deliveryMode == 4" class="">码科配送</view>
					<view v-if="info.deliveryMode == 5" class="">顺丰配送</view>
					<view v-if="info.deliveryMode == 6" class="">蜂鸟配送</view>
					<view v-if="info.deliveryMode == 7" class="">闪送配送</view>
					<view v-if="info.deliveryMode == 10" class="">自提</view>
				</view>
				<view class="f-x-bt mt10 f28">
					<view class="c9">配送员</view>
					<view v-if="info.deliveryInfo && info.deliveryInfo.riderName" class="">{{info.deliveryInfo.riderName}}</view>
				</view>
				<view class="f-x-bt mt10 f28">
					<view class="c9">手机号</view>
					<view v-if="info.deliveryInfo && info.deliveryInfo.riderTel" class="">{{info.deliveryInfo.riderTel}}</view>
				</view>
			</block>
			<view class="bt-fa wei f36 p20 mt50">订单费用</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">商品小计</view>
				<view class=""><text style="color: #67c23a;">{{info.originMoney}}</text>（注：商品折扣：￥{{ info.vipDiscount }}）</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">包装费</view>
				<view class="" style="color: #67c23a;">{{info.boxMoney}}</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">配送费</view>
				<view class="" style="color: #67c23a;">{{info.deliveryMoney}}</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">优惠</view>
				<view class=""><text style="color: #F56C6C;">{{info.discountMoney}}</text>（注:满减:￥{{ info.preferentialMoney }}，优惠券：￥{{ info.couponPreferential }}）</view>
			</view>
			<view class="f-x-bt mt10 f28" style="align-items: baseline;">
				<view class="c9" style="width: 200rpx;">平台服务费</view>
				<view class="">
					<text style="color: #F56C6C;">{{info.serviceMoney}}</text>
					<text v-if="query.type == 1 || query.type == 2">（注:商品:￥{{ info.serviceGoodMoney }}，包装费:￥{{ info.serviceBoxMoney }}，配送费:￥{{ info.serviceDeliveryMoney }}）</text>
					
				</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">平台补贴</view>
				<view class="" style="color: #F56C6C;">{{info.subsidy}}</view>
			</view>
			<view class="f-x-bt mt10 f28">
				<view class="c9">商户实际收入</view>
				<view class="" style="color: #67c23a;">{{info.storeActualMoney}} <text style="color: #F56C6C;">（顾客实际支付:￥{{ info.money }}）</text> </view>
			</view>
			<view style="padding-bottom: 200rpx;"></view>
		</block>
		<!-- 对账详情 end -->
	</view>
</template>

<script>
	export default {
		data(){
			return{
				type:'',
				info:{},
				query:{
					type:'',
					outTradeNo:''
				}
			}
		},
		onLoad(options) {
			this.type = options.type
			if(this.type === 'billDetail'){
				this.util.setNT('订单详情');
				this.query = uni.getStorageSync('flowListDetails')
				this.fetchData()
			}else{
				this.info = uni.getStorageSync('flowListDetails')
			}
		},
		methods:{
			async fetchData(){
				try {
					let {
						data
					} = await this.util.request({
						'url': this.api.currencyOrderInfo,
						data: this.query
					})
					this.info = data
				} catch (e) {
					this.util.message(e.msg, 3)
				}
			},
		}
	}
</script>

<style>
	.info{
		min-height: 100vh;
		background: #FFFFFF;
		padding-top: 50rpx;
	}
</style>
